﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;

using System.IO;
using System.Security.AccessControl;
using System.Web;
using System.Web.Script.Serialization;
using DataModel;
using System.Drawing;
using System.Drawing.Imaging;
using System.Web.Hosting;



namespace SocialPhotos {
	public class Thumbnail : IHttpHandler {
        SocialPhotoModelContainer model = new SocialPhotoModelContainer();

		public void ProcessRequest (HttpContext context) {
            try
            {
                context.Response.ContentType = "image";
                string fileName = context.Request["f"];
                if (fileName == null)
                    fileName = "DefaultThumbnail.png";
                string thumbnailFile = HostingEnvironment.MapPath("~/App_Data/Thumbnail/")
                    + fileName;
                context.Response.WriteFile(thumbnailFile);
            }
            catch (Exception ex)
            {
                //context.Response.WriteFile(ex.Message);
            }
		}

		public bool IsReusable { get { return false; } }
	}
}
